package com.prolestar.web.controller.report;

import com.prolestar.common.annotation.Log;
import com.prolestar.common.constant.ScheduleConstants;
import com.prolestar.common.core.controller.BaseController;
import com.prolestar.common.core.domain.AjaxResult;
import com.prolestar.common.core.page.TableDataInfo;
import com.prolestar.common.enums.BusinessType;
import com.prolestar.common.utils.poi.ExcelUtil;
import com.prolestar.report.domain.PsPublicsentimentReport;
import com.prolestar.report.domain.PsPublicsentimentReportVO;
import com.prolestar.report.service.IPsPublicsentimentReportService;
import com.prolestar.util.MySetPage;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 舆情上报Controller
 * 
 * @author ruoyi
 * @date 2022-11-11
 */
@RestController
@RequestMapping("/report/report")
public class PsPublicsentimentReportController extends BaseController
{
    @Autowired
    private IPsPublicsentimentReportService psPublicsentimentReportService;

    /**
     * 查询舆情上报列表
     */
    @PreAuthorize("@ss.hasPermi('report:report:list')")
    @GetMapping("/list")
    public TableDataInfo list(PsPublicsentimentReport psPublicsentimentReport)
    {
//        startPage();
        List<PsPublicsentimentReportVO> list = psPublicsentimentReportService.selectPsPublicsentimentReportList(psPublicsentimentReport);
//        return getDataTable(list);
        return MySetPage.mySetPage(list);
    }

    /**
     * 导出舆情上报列表
     */
    @PreAuthorize("@ss.hasPermi('report:report:export')")
    @Log(title = "舆情上报", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PsPublicsentimentReport psPublicsentimentReport)
    {
        List<PsPublicsentimentReport> list = psPublicsentimentReportService.selectPsPublicsentimentReportLists(psPublicsentimentReport);
        ExcelUtil<PsPublicsentimentReport> util = new ExcelUtil<PsPublicsentimentReport>(PsPublicsentimentReport.class);
        util.exportExcel(response, list, "舆情上报数据");
    }

    /**
     * 获取舆情上报详细信息
     */
    @PreAuthorize("@ss.hasPermi('report:report:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(psPublicsentimentReportService.selectPsPublicsentimentReportById(id));
    }

    /**
     * 新增舆情上报
     */
    @PreAuthorize("@ss.hasPermi('report:report:add')")
    @Log(title = "舆情上报", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PsPublicsentimentReport psPublicsentimentReport)
    {
        return toAjax(psPublicsentimentReportService.insertPsPublicsentimentReport(psPublicsentimentReport));
    }

    /**
     * 修改舆情上报
     */
    @PreAuthorize("@ss.hasPermi('report:report:edit')")
    @Log(title = "舆情上报", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PsPublicsentimentReport psPublicsentimentReport)
    {
        return toAjax(psPublicsentimentReportService.updatePsPublicsentimentReport(psPublicsentimentReport));
    }

    /**
     * 删除舆情上报
     */
    @PreAuthorize("@ss.hasPermi('report:report:remove')")
    @Log(title = "舆情上报", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(psPublicsentimentReportService.deletePsPublicsentimentReportByIds(ids));
    }

    /**
     * 舆情上报——上报操作
     * */
    @PostMapping("/appear")
//    @PreAuthorize("@ss.hasPermi('report:report:appear')")
    public AjaxResult appear(@RequestBody PsPublicsentimentReport psPublicsentimentReport){
         return psPublicsentimentReportService.appear(psPublicsentimentReport);
    }


    /**
     * 舆情上报--处理操作
     */
    @PostMapping("/dispose")
    @PreAuthorize("@ss.hasPermi('conservator,admin')")
    public AjaxResult dispose(@RequestBody PsPublicsentimentReport psPublicsentimentReport){
       return psPublicsentimentReportService.dispose(psPublicsentimentReport);

    }

    /**
     * 舆情上报——撤回处理
     */

    @PostMapping("/withdraw")
    public AjaxResult withdraw(@RequestBody PsPublicsentimentReport psPublicsentimentReport){
        return psPublicsentimentReportService.withdraw(psPublicsentimentReport);
    }






}
